feat: add mago analyze#205
Merged
Merged
Conversation
f41408c to
bca9b1a
Compare
Introduce a Static Analysis workflow that builds a full Magento install once and runs PHPStan and `mago analyze` against it in parallel, instead of each tool rebuilding Magento. Replaces the standalone PHPStan workflow (the PHPStan job keeps the same "PHPStan Analysis" check name). - static-analysis.yml: a build-magento job uploads the install as an artifact; the phpstan and mago-analyze jobs consume it without a live database (static analysis only reads code). phpstan.neon is copied into the install because it is export-ignored from the path-repo copy. - mago.toml: exclude phtml templates from analysis (runtime-injected template scope) and ignore the Magento-idiomatic mixed-assignment / mixed-operand codes (PHPStan level 9 is the type gate for those). - ddev: `ddev mago analyze` now runs against the installed Magento so it resolves the full class graph, matching what CI analyzes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
f7e383a to
ef638b2
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates static analysis CI into a single workflow that builds Magento once and reuses that build for multiple analyzers (PHPStan and Mago analyze), while also making small type-safety and prompt-filtering consistency tweaks across CLI/services to satisfy stricter static analysis.
Changes:
- Added a unified
.github/workflows/static-analysis.ymlthat builds Magento once and runs PHPStan + Mago analyze against the same artifact; removed the old dedicated PHPStan workflow. - Added local
ddev mago analyzesupport and tunedmago.tomlanalyzer settings (exclude*.phtml, ignore selected mixed-* codes). - Applied minor PHP type-safety adjustments and prompt option filtering cleanup across commands/services.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/Service/SymlinkCleaner.php |
Tightens typing when checking stat mode bits for symlink detection. |
src/Service/Inspector/Cache/BlockCacheCollector.php |
Adds Mago suppression comments around mixed-typed layout block iteration. |
src/Service/Hyva/IncompatibilityDetector.php |
Adds a Mago suppression for an argument-shape typing mismatch. |
src/Service/Hyva/CompatibilityChecker.php |
Adds a local PHPDoc type assertion for module path maps. |
src/Model/ThemePath.php |
Adds a local PHPDoc type assertion for registered theme path maps. |
src/Model/TemplateEngine/Decorator/InspectorHints.php |
Improves type casting/annotations for constants, render metrics, and dictionary keys. |
src/Console/Command/Theme/WatchCommand.php |
Simplifies interactive option filtering callback. |
src/Console/Command/Theme/TokensCommand.php |
Simplifies interactive option filtering callback. |
src/Console/Command/Theme/CleanCommand.php |
Simplifies interactive option filtering and enforces int index arithmetic. |
src/Console/Command/Theme/BuildCommand.php |
Simplifies interactive option filtering and enforces int index arithmetic. |
src/Console/Command/System/CheckCommand.php |
Minor quality improvements (constants/casts) and simplifies MySQL version query. |
src/Console/Command/Hyva/CompatibilityCheckCommand.php |
Ensures boolean option checks are explicitly boolean. |
mago.toml |
Configures analyzer excludes/ignores to make mago analyze usable on Magento code. |
.github/workflows/static-analysis.yml |
New consolidated CI workflow: build Magento once, run PHPStan + Mago analyze from artifact. |
.github/workflows/phpstan.yml |
Removes the old standalone PHPStan workflow in favour of the unified one. |
.ddev/commands/web/mago |
Adds a local mago analyze entrypoint matching CI’s analysis target/workspace. |
Fix the type errors mago analyze reports against a full Magento install:
- CheckCommand: cast ini_get('memory_limit') (string|false declared
string); use the PHP_VERSION constant instead of phpversion(); read the
MySQL version via fetchOne('SELECT VERSION()') instead of from(null).
- Type the loose getPaths() return via inline @var (array<string,string>)
in CompatibilityChecker and ThemePath.
- Cast mixed operands/arguments: theme loop index, hrtime() metrics,
stat() mode, and the getOption() flags used in a boolean expression.
- InspectorHints: widen render()'s $dictionary param to match the parent
TemplateEngineInterface; cast the BP constant to string.
- BlockCacheCollector: guard the untyped layout blocks with is_object()
so method_exists() is safe and both analyzers narrow the type (drops
the now-redundant @PHPStan-Ignore lines).
- IncompatibilityDetector: suppress the lone mago const-array-shape
finding with a scoped @mago-expect pragma (the shape is correct, as
PHPStan confirms).
- Drop redundant (string) casts and an obsolete @var docblock.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ef638b2 to
4f56577
Compare
dermatz
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new, consolidated static analysis workflow for the project, deprecating the old PHPStan workflow and adding support for the Mago static analyzer. It also includes several small code quality and consistency improvements across the codebase.
Static analysis workflow improvements:
.github/workflows/static-analysis.ymlto build Magento once and share the install across all static analysis jobs (PHPStan and Mago), improving CI efficiency and consistency. Also adds a dedicated Mago analyze job and ensures both analyzers run against the same codebase. (.github/workflows/static-analysis.yml).github/workflows/phpstan.yml)Mago static analyzer integration:
.ddev/commands/web/magoto support the newanalyzecommand, ensuring it runs against a full Magento install for accurate static analysis. (.ddev/commands/web/mago) [1] [2]mago.tomlto configure the analyzer: excludes.phtmltemplates and ignores low-confidencemixed-*type warnings, aligning with project standards. (mago.toml)Code quality and consistency:
PHP_VERSIONconstant, and ensuring correct return types). [1] [2] [3] [4] [5] [6] [7]